package com.linkage.jz.bankruptcy.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;

import com.linkage.jz.bankruptcy.Consts;
import com.linkage.jz.bankruptcy.utils.SPUtils;
import com.linkage.jz.bankruptcy.widget.ShapeLoadingDialog;

/**
 * @author AFAP
 * BaseFragment
 */
public class BaseFragment extends Fragment {
    protected ShapeLoadingDialog mShapeLoadingDialog;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mShapeLoadingDialog = new ShapeLoadingDialog(getActivity());
    }


    protected String getUserToken() {
        return SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
    }

    protected String getUserId() {
        return SPUtils.getInstance(Consts.SPNAME).getString("userId", "");
    }

    protected void showLoading(String text) {
        mShapeLoadingDialog.setLoadingText(text);
        mShapeLoadingDialog.setCanceledOnTouchOutside(false);
        mShapeLoadingDialog.show();
    }

    protected void hideLoading() {
        if (null != mShapeLoadingDialog) {
            mShapeLoadingDialog.dismiss();
        }
    }
}
